package com.three.config;

import com.three.controller.Chat;
import com.three.controller.GPT3;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Autowired
    private Chat chat;
    @Autowired
    private GPT3 gpt3;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry
                .addHandler(chat, "/chat")
                .setAllowedOrigins("*"); // 设置握手超时时间为 5 秒;
        registry.addHandler(gpt3, "/gpt3")
                .setAllowedOrigins("*");
    }
}
